# _*_ coding: UTF-8 _*_
# @Time     : 2021/11/3 下午 03:11
# @Author   : Li Jie
# @Site     : http://www.hzdledu.cn/
# @File     : case_001_login.py
# @Software : PyCharm
import time
import unittest
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from web5_po.page.login_page import LoginPage
from web5_po.page.main_page import MainPage


class LoginCase(unittest.TestCase):
    def setUp(self) -> None:
        self.driver = webdriver.Chrome()
        self.driver.maximize_window()

    def test(self):
        self.driver.get('http://192.168.6.189/cloud/#/open/login')
        time.sleep(1)
        self.driver.find_element_by_xpath('//*[@id="account"]/input').send_keys('admin')
        self.driver.find_element_by_xpath('//*[@id="password"]/input').send_keys('123456')
        self.driver.find_element_by_xpath('//*[@id="authCode"]/div/input').send_keys('8888')
        self.driver.find_element_by_xpath('//*[@id="root"]/div/div[1]/form/div[5]/div/div/span/button').click()  # 点击登录按键
        time.sleep(1)
        ActionChains(self.driver).click(self.driver.find_element_by_xpath('//*[@id="root"]/section/aside/div/ul/li[4]/div[1]/span')).perform()  # 点击系统管理
        time.sleep(1)
        ActionChains(self.driver).click(self.driver.find_element_by_xpath('//*[@id="sys$Menu"]/li[1]/a')).perform()  # 点击城市列表
        time.sleep(1)
        ActionChains(self.driver).click(self.driver.find_element_by_xpath('//*[@id="root"]/section/section/main/div/div[1]/button[1]')).perform()  # 点击添加按键
        time.sleep(1)
        self.driver.find_element_by_xpath('//*[@id="city"]').send_keys('xixi')
        time.sleep(1)
        self.driver.find_element_by_xpath('/html/body/div[2]/div/div[2]/div/div[2]/div[3]/button').click()
        time.sleep(1)

    def tearDown(self) -> None:
        self.driver.quit()
